/**
 * \file CodeProfile.h
 * \brief CodeProfile declaration class
 * \author Edouard ROGE
 * \date 16 October 2012
 */
#ifndef _CODEPROFILE_
#define _CODEPROFILE_

#include <thread>
#include "Core/Define/Define.h"

namespace Core
{
	namespace Profile
	{
		/**
		* \class CodeProfile
		* \brief Measure in milliseconds a piece of code where this object exists.
		*/
		class CodeProfile
		{
		public:

			/**
			 * \fn CodeProfile(const char * _name);
			 * \param _name name of the function to profile
			 * \brief Constructor and start profiling
			 */
			CodeProfile(const char * _name);

			/**
			 * \fn CodeProfile(const char * _name, std::thread::id _parentThreadId);
			 * \param _name name of the function to profile
			 * \param _parentThreadId id of the parent thread
			 * \brief Constructor and start profiling
			 */
			CodeProfile(const char * _name, std::thread::id _parentThreadId);

			/**
			 * \fn ~CodeProfile();
			 * \brief Destructor and stop profiling
			 */
			~CodeProfile();

		private:

			/** index of the time in the vector */
			uint32 m_iIndexTimeMeasure;
		};
	}
}

/** Macro for profiling */
#define PROFILE(name) Core::Profile::CodeProfile codeProfile(name);

#define PROFILEEX(name, parent) Core::Profile::CodeProfile codeProfile(name, parent);


#endif // _CODEPROFILE_
